Skip to content

Scheduled weekly dependency update for week 28#449

Closed
pyup-bot wants to merge 15 commits into
mainfrom
pyup-scheduled-update-2026-07-13
Closed

Scheduled weekly dependency update for week 28#449
pyup-bot wants to merge 15 commits into
mainfrom
pyup-scheduled-update-2026-07-13

Conversation

@pyup-bot

Copy link
Copy Markdown
Collaborator

Update fonttools from 4.62.1 to 4.63.0.

Changelog

4.63.0

----------------------------

- [ttLib] Add support for Apple Color Emoji ``bgcl`` table (4065).
- [ttLib] Add support for ``IFT`` and ``IFTX`` tables (Incremental Font Transfer,
PatchMapFormat2) (4070, 4072).
- [otData] Introduce ``FieldSpec`` dataclass for OpenType table schema definitions,
replacing raw tuples in ``otData.py`` (4076).
- [Feat] Show ``name`` table strings as comments next to label IDs in TTX output,
matching the convention used by ``fvar``, ``STAT``, ``trak`` (4089).
- [cu2qu] Fix Cython complex-division rounding difference in
``split_cubic_into_three`` that could cause ±1 off-curve coordinate shifts
(3928, 4083).
- [designspaceLib] Fix ``map_backward`` for many-to-one (flat-segment) axis maps
that silently dropped entries via dict comprehension
(googlefonts/ufo2ft978, 4085).
- [OS/2] Fix ``setUnicodeRanges`` to accept reserved bits 123-127, restoring
round-trip with ``getUnicodeRanges`` and fixing ``recalcUnicodeRanges`` crash
in the subsetter (4087, 4088).
- [cython] Declare Cython extensions as free-threading compatible on Python 3.13+,
so that importing them on free-threaded Python no longer re-enables the GIL
(4073, 4090).
Links

Update lxml from 6.1.0 to 6.1.1.

Changelog

6.1.1

==================

Bugs fixed
----------

* The known link attributes in ``lxml.html.defs.link_attrs`` were missing ``xlink:href``,
which can be used for URL bypass attacks in embedded SVG/MathML/etc. content.
https://github.com/fedora-python/lxml_html_clean/security/advisories/GHSA-4jhm-jv67-739f

* The Linux wheels use a patched libxslt 1.1.43, fixing CVE-2025-7424 and CVE-2025-11731.

* The Windows wheels use libxslt 1.1.45, fixing CVE-2025-7424 and CVE-2025-11731.
Links

Update msgpack from 1.1.2 to 1.2.1.

The bot wasn't able to find a changelog for this release. Got an idea?

Links

Update orjson from 3.11.7 to 3.11.9.

Changelog

3.11.9

Changed

- Build now depends on Rust 1.95 or later instead of 1.89.

Fixed

- Fix building on Rust 1.95.

3.11.8

Changed

- Build and compatibility improvements.
Links

Update typing-extensions from 4.15.0 to 4.16.0.

Changelog

4.16.0

No user-facing changes since 4.16.0rc2.

4.16.0rc2

- Avoid a `DeprecationWarning` when `deprecated` is applied to a coroutine function on
Python 3.14.0.

4.16.0rc1

- Make `typing_extensions.TypeAliasType`'s `__module__` attribute writable.
Backport of CPython PR
[149172](https://github.com/python/cpython/pull/149172).
- Fix setting of `__required_keys__` and `__optional_keys__` when inheriting
keys with the same name.
- Add support for `AsyncIterator`, `io.Reader`, `io.Writer` and `os.PathLike` protocols
as bases for other protocols.
- Fix incorrect behaviour on Python 3.9 and Python 3.10 that meant that
calling `isinstance` with `typing_extensions.Concatenate[...]` or
`typing_extensions.Unpack[...]` as the first argument could have a different
result in some situations depending on whether or not a profiling function had been
set using `sys.setprofile`. This affected both CPython and PyPy implementations.
Patch by Brian Schubert.
- Fix `__init_subclass__()` behavior in the presence of multiple inheritance involving
an `deprecated`-decorated base class. Backport of CPython PR
[138210](https://github.com/python/cpython/pull/138210) by Brian Schubert.
- Raise `TypeError` when attempting to subclass `typing_extensions.ParamSpec` on
Python 3.9. The `typing` implementation has always raised an error, and the
`typing_extensions` implementation has raised an error on Python 3.10+ since
`typing_extensions` v4.6.0. Patch by Brian Schubert.
- Add the `bound`, `covariant`, `contravariant`, and `infer_variance` parameters
to `TypeVarTuple`.
- Officially support the `bound`, `covariant`, `contravariant` and `infer_variance`
parameters to `ParamSpec`. Improve the validation of these parameters at runtime.
- Rename `typing_extensions.Sentinel` to `typing_extensions.sentinel`, following the
name that has been adopted for `builtins.sentinel` on Python 3.15.
`typing_extensions.Sentinel` is retained as a soft-deprecated alias for backwards
compatibility.
- Add support for pickling sentinels.
- Sentinels now preserve their identity when copied or deep-copied.
- Deprecate passing `name` as a keyword argument or `repr` as a positional argument
to the `sentinel` constructor.
- The default repr of a sentinel `X = sentinel("X")` is now `X` rather than `<X>`.
- Deprecate arbitrary attribute assignments to sentinels.
- Deprecate subclassing sentinels.
- Add support for Python 3.15.
Links

Update black from 26.3.1 to 26.5.1.

Changelog

26.5.1

Stable style

- Fix unstable formatting of annotated assignments whose subscript annotation contains
an inline comment (e.g. `x: list[   pyright: ignore[...]`) (5130)
- Preserve inline comments (including ` type: ignore`) immediately before a
` fmt: skip` line, avoiding AST equivalence failures (5139)

Packaging

- Correct the version in the published executables (5137)

Documentation

- Add Neovim integration guide covering conform.nvim, ALE, and simple command approaches
(5124)

26.5.0

Highlights

- Add support for unpacking in comprehensions (PEP 798) and for lazy imports (PEP 810),
both new syntactic features in Python 3.15 (5048)
- Python 3.15 is now supported. Compiled wheels are not yet provided for Python 3.15, so
performance may be slower than on existing Python versions. Wheels will be provided
once Python 3.15 is later in its release cycle. (5127)

Stable style

- Fix ` fmt: skip` being ignored in nested `if` expressions with parenthesized `in`
clauses (4903)
- Add syntactic support for Python 3.15 (5048)
- Fix crash when an f-string follows a ` fmt: off` comment inside brackets (5097)
- Preserve multiline compound statement headers when ` fmt: skip` is placed on the
colon line (5117)

Preview style

- Improve heuristics around whether blank lines should appear before, within and after
groups of same-name decorated functions (such as `overload` groups) in `.pyi` stub
files (5021)
- Fix blank lines being removed between a function and a decorated class in `.pyi` stub
files (5092)
- Prevent string merger from creating unsplittable long lines when a pragma comment
(e.g. ` type: ignore`) follows the closing bracket (5096)

Packaging

- Run CI on 3.15 (5127)

Output

- Improve parse error readability by showing multi-line output with an error pointer.
(5068)
- Add `SourceASTParseError` to distinguish source parse failures from internal safety
errors, improving error reporting when Black's lenient parser accepts input that
`ast.parse()` rejects (5080)

_Blackd_

- Return HTTP 400 (Bad Request) for source parse failures instead of HTTP 500, keeping
HTTP 500 only for genuine internal safety errors (5080)

Integrations

- Added documentation for doctest formatting tools and updated the integrations index to
match (4916)

Documentation

- Use "Version X.Y.Z" headings in changelog for stable permalink anchors on ReadTheDocs
(5063)
- Note in the editor integrations that the SublimeText `sublack` plugin is archived and
unmaintained (5082)
Links

Update click from 8.3.1 to 8.4.2.

Changelog

8.4.2

Unreleased

- Fix Fish shell completion broken in `8.4.0` by {pr}`3126`. Newlines and
tabs in option help text are now escaped, keeping the original completion
format while still supporting multi-line help. {issue}`3502`
{issue}`3043` {pr}`3504` {pr}`3508`
- Deprecated commands and options with empty or missing help text no longer
render a stray leading space before the `(DEPRECATED)` label. {pr}`3509`
- A {class}`Group` with `invoke_without_command=True` marks its subcommand as
optional in the usage help, showing `[COMMAND]` instead of `COMMAND`.
{issue}`3059` {pr}`3507`
- `echo_via_pager` flushes after each write, so passing a generator streams
output to the pager incrementally instead of staying hidden until the pipe
buffer fills. {issue}`3242` {issue}`2542` {pr}`3534`
- `echo_via_pager` and `get_pager_file` no longer close a borrowed stdout
stream when no external pager runs, completing the partial
`I/O operation on closed file` fix from {pr}`3482`. {issue}`3449`
{pr}`3533`

8.4.1

Released 2026-05-21

- `get_parameter_source()` is available during eager callbacks and type
conversion again. {issue}`3458` {pr}`3484`
- Zsh completion scripts parse correctly on Windows. {issue}`3277` {pr}`3466`
- Shell completion of `Enum` values used as `Choice` options produces a
valid completion result. {issue}`3015` {pr}`3471`
- Fix empty byte-string handling in echo. {issue}`3487` {pr}`3493`
- Fix closed file error with `echo_via_pager`. {issue}`3449` {pr}`3482`
- Fix `open_url` on Windows when the file path contains spaces.
{issue}`2994` {pr}`3478`

8.4.0

Released 2026-05-17

- {class}`ParamType` typing improvements. {pr}`3371`

- {class}`ParamType` is now a generic abstract base class,
 parameterized by its converted value type.
- {meth}`~ParamType.convert` return types are narrowed on all
 concrete types (`str` for {class}`STRING`, `int` for
 {class}`INT`, etc.).
- {meth}`~ParamType.to_info_dict` returns specific
 {class}`~typing.TypedDict` subclasses instead of
 `dict[str, Any]`.
- {class}`CompositeParamType` and the number-range base are now
 generic with abstract methods.

- Refactor `convert_type` to extract type inference into a private
`_guess_type` helper, and add {func}`typing.overload` signatures.
{pr}`3372`

- {class}`Parameter` typing improvements. {pr}`2805`

- {class}`Parameter` is now an abstract base class, making explicit
 that it cannot be instantiated directly.
- {attr}`Parameter.name` is now `str` instead of `str | None`.
 When `expose_value=False`, the name is set to `""` instead
 of `None`.
- The `ctx` parameter of {meth}`Parameter.get_error_hint` is now
 typed as `Context | None`, matching the runtime behavior.

- Split string values from `default_map` for parameters with `nargs > 1`
or {class}`Tuple` type, matching environment variable behavior.
{issue}`2745` {pr}`3364`

- Auto-detect `type=UNPROCESSED` for `flag_value` of non-basic types
(not `str`, `int`, `float`, or `bool`), so programmer-provided
Python objects like classes and enum members are passed through unchanged
instead of being stringified. Previously `type=click.UNPROCESSED` had
to be set explicitly. {issue}`2012` {pr}`3363`

- The error hint now uses {meth}`Command.get_help_option_names` to pick
non-shadowed help option names, so `Try '... -h'` no longer points to a
subcommand option that shadows `-h`. The longest surviving name is
shown (`--help` over `-h`) for readability. {issue}`2790` {pr}`3208`

- Fix readline functionality on non-Windows platforms. Prompt text is now
passed directly to readline instead of being printed separately, allowing
proper backspace, line editing, and line wrapping behavior. {issue}`2968`
{pr}`2969`

- Use {func}`os.startfile` on Windows to open URLs in {func}`open_url`,
replacing the `start` built-in which cannot be invoked without
`shell=True`. {issue}`2868` {issue}`3164` {pr}`3186`

- Fix Fish shell completion errors when option help text contains newlines.
{issue}`3043` {pr}`3126`

- Add {class}`NoSuchCommand` exception with suggestions for misspelled
commands. {issue}`3107` {pr}`3228`

- Use {class}`ValueError` message when conversion in {class}`FuncParamType` would
fail. {issue}`3105` {pr}`3211`

- Add `click.get_pager_file` for file-like access to an output
pager. {pr}`1572` {pr}`3405`

- {func}`~click.formatting.wrap_text` now measures line width in visible
characters, ignoring ANSI escape sequences. {pr}`3420`

- Fix {meth}`HelpFormatter.write_usage` emitting only a blank line when
called without `args`. The usage prefix and program name are now
written even when no arguments follow, and the trailing separator
space is stripped so the line ends at the program name.
{issue}`3360` {pr}`3434`

- Show custom error messages from types when {func}`prompt` with
`hide_input=True` fails validation, instead of always showing a
generic message. Built-in type messages mask the input value.
{issue}`2809` {pr}`3256`

- Add `capture` parameter to {class}`CliRunner` with two modes: `sys`
(default) and `fd`. `fd` redirects file descriptors `1` and `2`
via {func}`os.dup2` so output that bypasses `sys.stdout` (stale stream
references, C extensions, subprocesses, `faulthandler`) is captured
with proper isolation. {issue}`854` {issue}`2412` {issue}`2468`
{issue}`2497` {issue}`2761` {issue}`2827` {issue}`2865` {pr}`3391`

- Revert the `8.3.3` change that exposed the original file descriptor
via `fileno()` on the redirected `CliRunner` streams in the default
capture mode. `os.dup2(w, sys.stdout.fileno())` calls inside a CLI no
longer mutate the host runner's stdout, which broke Pytest's `fd`-level
capture teardown. C-level consumers that need a real `fd` should use
`capture="fd"`. {issue}`3384` {pr}`3391`

- Mark additional built-in strings with `gettext()` to extend translation
coverage. {pr}`2902`

- Fix feature switch groups (several `flag_value` options sharing one
parameter name) silently dropping an explicit `default` when a sibling
option without an explicit default was declared first. Arbitration is now
source-aware: a more explicit {class}`ParameterSource` always wins, and
within `ParameterSource.DEFAULT`, an option that received an explicit
`default=` keyword wins over a sibling whose default was auto-derived.
The 8.3.x first-wins fallback for remaining ties was reverted to the
pre-8.3.x last-wins fallback. {issue}`3403` {pr}`3404`

- Fix missing space between option help text and the `(DEPRECATED)`
label, and localize the option label so it matches the command label.
The label and the `DeprecationWarning` reason suffix are now produced
by shared helpers. {pr}`3423`

- Document short option stacking (`-abc` is parsed as `-a -b -c`) and
clarify that multi-character short option names are not supported.
{issue}`2779` {pr}`3431`

8.3.3

Released 2026-04-20

- Use {func}`shlex.split` to split pager and editor commands into `argv`
lists for {class}`subprocess.Popen`, removing `shell=True`.
{issue}`1026` {pr}`1477` {pr}`2775`
- Fix `TypeError` when rendering help for an option whose default value is
an object that doesn't support equality comparison with strings, such as
`semver.Version`. {issue}`3298` {pr}`3299`
- Fix pager test pollution under parallel execution by using pytest's
`tmp_path` fixture instead of a shared temporary file path. {pr}`3238`
- Treat `Sentinel.UNSET` values in a `default_map` as absent, so they fall
through to the next default source instead of being used as the value.
{issue}`3224` {pr}`3240`
- Patch `pdb.Pdb` in `CliRunner` isolation so `pdb.set_trace()`,
`breakpoint()`, and debuggers subclassing `pdb.Pdb` (ipdb, pdbpp) can
interact with the real terminal instead of the captured I/O streams.
{issue}`654` {issue}`824` {issue}`843` {pr}`951` {pr}`3235`
- Add optional randomized parallel test execution using `pytest-randomly` and
`pytest-xdist` to detect test pollution and race conditions. {pr}`3151`
- Add contributor documentation for running stress tests, randomized
parallel tests, and Flask smoke tests. {pr}`3151` {pr}`3177`
- Show custom `show_default` string in prompts, matching the existing
help text behavior. {issue}`2836` {pr}`2837` {pr}`3165` {pr}`3262` {pr}`3280`
{pr}`3328`
- Fix `default=True` with boolean `flag_value` always returning the
`flag_value` instead of `True`. The `default=True` to `flag_value`
substitution now only applies to non-boolean flags, where `True` acts as a
sentinel meaning "activate this flag by default". For boolean flags,
`default=True` is returned as a literal value. {issue}`3111` {pr}`3239`
- Mark `make_default_short_help` as private API. {issue}`3189` {pr}`3250`
- `CliRunner`'s redirected streams now expose the original file descriptor
via `fileno()`, so that `faulthandler`, `subprocess`, and other
C-level consumers no longer crash with `io.UnsupportedOperation`.
{issue}`2865`
- Change {class}`ParameterSource` to an {class}`~enum.IntEnum` and reorder
its members from most to least explicit, so values can be compared to
check whether a parameter was explicitly provided. {issue}`2879` {pr}`3248`

8.3.2

Released 2026-04-02

- Fix handling of `flag_value` when `is_flag=False` to allow such options to be
used without an explicit value. {issue}`3084` {pr}`3152`
- Hide `Sentinel.UNSET` values as `None` when using `lookup_default()`.
{issue}`3136` {pr}`3199` {pr}`3202` {pr}`3209` {pr}`3212` {pr}`3224`
- Prevent `_NamedTextIOWrapper` from closing streams owned by `StreamMixer`.
{issue}`824` {issue}`2991` {issue}`2993` {issue}`3110` {pr}`3139` {pr}`3140`
- Add comprehensive tests for `CliRunner` stream lifecycle, covering
logging interaction, multi-threaded safety, and sequential invocation
isolation. Add high-iteration stress tests behind a `stress` marker
with a dedicated CI job. {pr}`3139`
- Fix callable `flag_value` being instantiated when used as a default via
`default=True`. {issue}`3121` {pr}`3201` {pr}`3213` {pr}`3225`
Links

Update coverage from 7.13.5 to 7.15.1.

Changelog

7.15.1

---------------------------

- Fix: in the HTML report with ``show_contexts`` enabled, a context label
containing ``</script>`` (for example a parametrized pytest node id) could
close the inline ``<script>`` element in a file page early, injecting markup.
Context labels are now fully escaped. Thanks, `Rajath Mohare <pull 2224_>`_.

- A number of performance improvements thanks to Paul Kehrer, in pull requests
`2213 <pull 2213_>`_, `2214 <pull 2214_>`_, `2215 <pull 2215_>`_, `2216
<pull 2216_>`_, `2218 <pull 2218_>`_, `2220 <pull 2220_>`_, and `2221 <pull
2221_>`_.

.. _pull 2213: https://github.com/coveragepy/coveragepy/pull/2213
.. _pull 2214: https://github.com/coveragepy/coveragepy/pull/2214
.. _pull 2215: https://github.com/coveragepy/coveragepy/pull/2215
.. _pull 2216: https://github.com/coveragepy/coveragepy/pull/2216
.. _pull 2218: https://github.com/coveragepy/coveragepy/pull/2218
.. _pull 2220: https://github.com/coveragepy/coveragepy/pull/2220
.. _pull 2221: https://github.com/coveragepy/coveragepy/pull/2221
.. _pull 2224: https://github.com/coveragepy/coveragepy/pull/2224

.. _changes_7-15-0:

7.15.0

---------------------------

- Since 7.14.0, reporting commands implicitly combine parallel data files. Now
those commands have a new option ``--keep-combined`` to retain the data files
after combining them instead of the default, which is to delete them.
Finishes `issue 2198`_.

- Fix: the LCOV report would incorrectly count excluded functions as uncovered,
as described in `issue 2205`_. This is now fixed thanks to `Martin Kuntz
Jacobsen <pull 2206_>`_.

- When running your program, coverage now correctly sets
``yourmodule.__spec__.loader`` as `strongly recommended <--loader--_>`_,
avoiding the deprecation warning described in `issue 2208`_. Thanks, `A5rocks
<pull 2209_>`_.

- Fix: with Python 3.10, running with the ``-I`` (isolated mode) option didn't
correctly omit the current directory from the module search path, as
described in `issue 2103`_. That is now fixed thanks to `Ilia Sorokin <pull
2211_>`_.

.. _--loader--: https://docs.python.org/3/reference/datamodel.html#module.__loader__
.. _issue 2103:  https://github.com/coveragepy/coveragepy/issues/2103
.. _issue 2198:  https://github.com/coveragepy/coveragepy/issues/2198
.. _issue 2205:  https://github.com/coveragepy/coveragepy/issues/2205
.. _pull 2206: https://github.com/coveragepy/coveragepy/pull/2206
.. _issue 2208:  https://github.com/coveragepy/coveragepy/issues/2208
.. _pull 2209: https://github.com/coveragepy/coveragepy/pull/2209
.. _pull 2211: https://github.com/coveragepy/coveragepy/pull/2211


.. _changes_7-14-3:

7.14.3

---------------------------

- Fix: the default ``...`` exclusion rule now also matches function bodies
whose closing return-type bracket is on its own line (for example, after a
long ``-> dict[ ... ]`` annotation that a formatter has split over multiple
lines). Closes `issue 2185`_, thanks `Mengjia Shang <pull 2196_>`_.

- Fix: On 3.13t, we incorrectly issued ``Couldn't import C tracer`` errors.
We can't import the C tracer because in 7.14.2 we stopped shipping compiled
wheels for 3.13t. Thanks, `Hugo van Kemenade <pull 2203_>`_.

.. _issue 2185: https://github.com/coveragepy/coveragepy/issues/2185
.. _pull 2196: https://github.com/coveragepy/coveragepy/pull/2196
.. _pull 2203: https://github.com/coveragepy/coveragepy/pull/2203


.. _changes_7-14-2:

7.14.2

---------------------------

- Fix: some messages were being written to stdout, making ``coverage json -o
-`` useless for capturing JSON output. Now messages are written to stderr,
fixing `issue 2197`_.

- Fix: ``CoverageData`` kept one SQLite connection per thread that recorded
coverage, but never closed them when those threads terminated. On long runs
with many short-lived threads this leaked one file descriptor per dead
thread, eventually failing with ``OSError: [Errno 24] Too many open files``.
Connections belonging to terminated threads are now closed and dropped.
Fixes `issue 2192`_.  Thanks, `Matthew Lloyd <pull 2193_>`_.

- Fix: when using sys.monitoring, we were assuming we could use the
``COVERAGE_ID`` tool id.  But other tools might also assume they could use
that id.  Pre-allocated ids don't really make sense, so now we search for a
usable one instead. Fixes `issue 2187`_.

- Following `the advice of cibuildwheel <no-13t_>`_, we no longer distribute
wheels for Python 3.13 free-threaded.

.. _issue 2187: https://github.com/coveragepy/coveragepy/issues/2187
.. _issue 2192: https://github.com/coveragepy/coveragepy/issues/2192
.. _pull 2193: https://github.com/coveragepy/coveragepy/pull/2193
.. _issue 2197: https://github.com/coveragepy/coveragepy/issues/2197
.. _no-13t: https://py-free-threading.github.io/ci/#building-free-threaded-wheels-with-cibuildwheel


.. _changes_7-14-1:

7.14.1

---------------------------

- Fix: the HTML report used typographic niceties to make file paths more
readable by adding a small amount of space around slashes. Those spaces
interfered with searching the page for file paths of interest. Now the report
uses CSS to accomplish the same visual tweak so that searches with slashes
work correctly. Closes `issue 2170`_.

- `Add a 3.16 PyPI classifier <hugo-316_>`_ since we test on the 3.16 main
branch.

.. _issue 2170: https://github.com/coveragepy/coveragepy/issues/2170
.. _hugo-316: https://mastodon.social/hugovk/116588523571204490


.. _changes_7-14-0:

7.14.0

---------------------------

- Feature: now when running one of the reporting commands, if there are
parallel data files that need combining, they will be implicitly combined
before creating the report. There is no option to avoid the combination; let
us know if you have a use case that requires it.  Thanks, `Tim Hatch
<pull 2162_>`_. Closes `issue 1781`_.

- Fix: the output from ``combine`` was too verbose, listing each file
considered. Now it shows a single line with the counts of files combined,
files skipped, and files with errors. The ``-q`` flag suppresses this line.
The old detailed lines are available with the new ``--debug=combine`` option.

- Fix: running a Python file through a symlink now sets the sys.path correctly,
matching regular Python behavior. Fixes `issue 2157`_.

- Fix: ``Collector.flush_data`` could fail with "RuntimeError: Set changed
size during iteration" when a tracer in another thread added a line to the
per-file set that ``add_lines`` (or ``add_arcs``) was iterating. The values
passed to ``CoverageData`` are now snapshotted via ``dict.copy()`` and
``set.copy()``, which are atomic under the GIL. Thanks, `Alex Vandiver <pull
2165_>`_.

- Fix: the soft keyword ``lazy`` is now bolded in HTML reports.

- We are no longer testing eventlet support. Eventlet started issuing stern
deprecation warnings that break our tests. Our support code is still there.

.. _issue 1781: https://github.com/coveragepy/coveragepy/issues/1781
.. _issue 2157: https://github.com/coveragepy/coveragepy/issues/2157
.. _pull 2162: https://github.com/coveragepy/coveragepy/pull/2162
.. _pull 2165: https://github.com/coveragepy/coveragepy/pull/2165


.. _changes_7-13-5:
Links

Update librt from 0.8.1 to 0.13.0.

The bot wasn't able to find a changelog for this release. Got an idea?

Links

Update mypy from 1.19.1 to 2.3.0.

Changelog

2.3

We've just uploaded mypy 2.3.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
Mypy is a static type checker for Python. This release includes new features, performance
improvements and bug fixes. You can install it as follows:

 python3 -m pip install -U mypy

You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).

The Upcoming Switch to the New Native Parser

We are planning to enable the new native parser (`--native-parser`) by
default soon. We recommend that you test the native parser in your projects and report
any issues in the [mypy issue tracker](https://github.com/python/mypy/issues).

Mypyc Free-threading Memory Safety

Free-threaded Python builds that don't have the GIL require additional synchronization
primitives or lock-free algorithms to ensure memory safety when there are race conditions
(for example, when a thread reads a list item while another thread writes the same list
item concurrently). This release greatly improves memory safety of free threading.

List operations are now memory-safe on free threaded Python builds, even in the presence of
race conditions. This has some performance cost. For list-heavy workloads, using
`librt.vecs.vec` instead of list is often significantly faster, but note that `vec` is not
(and likely won't be) fully memory safe, and the user is expected to avoid race conditions.
The newly introduced `librt.threading.Lock` helps with this. Using variable-length tuples
can also be more efficient than lists, since tuples are immutable and don't require
expensive synchronization to ensure memory safety.

Instance attribute access is also (mostly) memory safe now on free-threaded builds in
the presence of race conditions. We are planning to fix the remaining unsafe cases in a
future release.

Full list of changes:

- Make attribute access memory safe on free-threaded builds (Jukka Lehtosalo, PR [21705](https://github.com/python/mypy/pull/21705))
- Fix unsafe borrowing of instance attributes with free-threading (Jukka Lehtosalo, PR [21688](https://github.com/python/mypy/pull/21688))
- Make list get/set item more memory safe on free-threaded builds (Jukka Lehtosalo, PR [21683](https://github.com/python/mypy/pull/21683))
- Don't borrow list items on free-threaded builds (Jukka Lehtosalo, PR [21679](https://github.com/python/mypy/pull/21679))
- Make multiple assignment from list memory-safe on free-threaded builds (Jukka Lehtosalo, PR [21684](https://github.com/python/mypy/pull/21684))
- Make `for` loop over list memory-safe on free-threaded builds (Jukka Lehtosalo, PR [21686](https://github.com/python/mypy/pull/21686))
- Fix memory safety of `list.count` on free-threaded builds (Jukka Lehtosalo, PR [21680](https://github.com/python/mypy/pull/21680))
- Make `vec` creation from list memory safe on free-threaded builds (Jukka Lehtosalo, PR [21681](https://github.com/python/mypy/pull/21681))

librt.threading: Fast Native Lock Type

Mypyc now supports `librt.threading.Lock`, which is a lock type optimized for use
in compiled code. It can be 2x to 4x faster than `threading.Lock`.

This feature was contributed by Jukka Lehtosalo (PR [21690](https://github.com/python/mypy/pull/21690), PR [21697](https://github.com/python/mypy/pull/21697)).

Mypyc: Read-only Final Instance Attributes

Instance attributes of native classes declared as `Final` are now read-only at runtime.
This enables additional optimizations, and it's now recommended to use `Final` for
all performance-sensitive attributes when feasible.

Related changes:

- Make instance attribute read-only at runtime if `Final` (Jukka Lehtosalo, PR [21666](https://github.com/python/mypy/pull/21666))
- Borrow final attributes more aggressively (Jukka Lehtosalo, PR [21702](https://github.com/python/mypy/pull/21702))
- Improve documentation of `Final` in mypyc (Jukka Lehtosalo, PR [21713](https://github.com/python/mypy/pull/21713))

Mypyc Documentation Updates

- Update documentation of race conditions under free threading (Jukka Lehtosalo, PR [21726](https://github.com/python/mypy/pull/21726))
- Update mypyc free threading Python compatibility docs (Jukka Lehtosalo, PR [21711](https://github.com/python/mypy/pull/21711))
- Document recent additions to `librt.strings`, such as `ispace` (Jukka Lehtosalo, PR [21696](https://github.com/python/mypy/pull/21696))

Miscellaneous Mypyc Improvements

- Fix reference leak when setting unboxed refcounted attributes (Tom Bannink, PR [21657](https://github.com/python/mypy/pull/21657))
- Fix function wrapper memory leak (Piotr Sawicki, PR [21654](https://github.com/python/mypy/pull/21654))
- Fix handling of invalid codepoint values in `librt.strings` (Jukka Lehtosalo, PR [21634](https://github.com/python/mypy/pull/21634))
- Fix non-deterministic ordering of spilled registers (Jukka Lehtosalo, PR [21632](https://github.com/python/mypy/pull/21632))
- Fix non-deterministic compiler output due to frozensets (Jukka Lehtosalo, PR [21631](https://github.com/python/mypy/pull/21631))

Changes to Messages

- Fix error code of note about unbound type variable (Jukka Lehtosalo, PR [21668](https://github.com/python/mypy/pull/21668))

Other Notable Fixes and Improvements

- Use `PYODIDE` environment variable for Emscripten cross-compilation detection (Agriya Khetarpal, PR [21714](https://github.com/python/mypy/pull/21714))
- Narrow for frozendict membership check (Shantanu, PR [21709](https://github.com/python/mypy/pull/21709))
- Fix custom equality handling for membership narrowing in static containers (Shantanu, PR [21706](https://github.com/python/mypy/pull/21706))
- Infer `Coroutine` for unannotated async functions (Jingchen Ye, PR [21651](https://github.com/python/mypy/pull/21651))
- Fix variance inference issues caused by dataclass replace (Shantanu, PR [21694](https://github.com/python/mypy/pull/21694))
- Fix regression in dataclass narrowing for Python >= 3.13 (ygale, PR [21675](https://github.com/python/mypy/pull/21675))
- Fix star import dependencies in mypy daemon (Jukka Lehtosalo, PR [21673](https://github.com/python/mypy/pull/21673))
- Fix skipped imports considered stale (Piotr Sawicki, PR [21639](https://github.com/python/mypy/pull/21639))
- Support `.ff` files with `--cache-map` (Jukka Lehtosalo, PR [21633](https://github.com/python/mypy/pull/21633))

Typeshed Updates

Please see [git log](https://github.com/python/typeshed/commits/main?after=f76037a1eb3923c67a8bc0e302ee9c016ffb3431+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.

Acknowledgements

Thanks to all mypy contributors who contributed to this release:

- Agriya Khetarpal
- Ethan Sarp
- Ivan Levkivskyi
- Jingchen Ye
- Jukka Lehtosalo
- Piotr Sawicki
- Shantanu
- Tom Bannink
- Viktor Szépe
- ygale

I'd also like to thank my employer, Dropbox, for supporting mypy development.

2.2

We've just uploaded mypy 2.2.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
Mypy is a static type checker for Python. This release includes new features, performance
improvements and bug fixes. You can install it as follows:

 python3 -m pip install -U mypy

You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).

Support for Closed TypedDicts (PEP 728)

Mypy now supports closed TypedDicts as specified in PEP 728. A closed TypedDict cannot have extra
keys beyond those explicitly defined. This allows the type checker to determine that certain
operations are safe when they otherwise wouldn't be due to the potential presence of unknown keys.

You can use the `closed` keyword argument with `TypedDict`:

python
HasName = TypedDict("HasName", {"name": str})
HasOnlyName = TypedDict("HasOnlyName", {"name": str}, closed=True)
Movie = TypedDict("Movie", {"name": str, "year": int})

movie: Movie = {"name": "Nimona", "year": 2023}
has_name: HasName = movie   OK: HasName is open (default)
has_only_name: HasOnlyName = movie   Error: HasOnlyName is closed and Movie has extra "year" key


Closed TypedDicts enable more precise type checking because the type checker knows exactly which
keys are present. This is particularly useful when working with TypedDict unions or when you want
to ensure that a TypedDict conforms to an exact shape.

The `closed` keyword also enables safe type narrowing with `in` checks:

python
Book = TypedDict('Book', {'book': str}, closed=True)
DVD = TypedDict('DVD', {'dvd': str}, closed=True)
type Inventory = Book | DVD

def print_type(inventory: Inventory) -> None:
 if "book" in inventory:
      Type is narrowed to Book here - safe because DVD is closed
     print(inventory["book"])
 else:
      Type is narrowed to DVD here
     print(inventory["dvd"])


The `closed` keyword is also supported in class-based syntax:

python
class HasOnlyName(TypedDict, closed=True):
 name: str


Note that closed TypedDicts are structural types, so a closed TypedDict is assignable to an open
TypedDict with the same keys, but not vice versa.

Contributed by Alice (PR [21382](https://github.com/python/mypy/pull/21382)).

Complete Support for Type Variable Defaults (PEP 696)

Mypy now has complete support for type variable defaults as specified in PEP 696. This allows you to
specify default values for type parameters in generic classes, functions, and type aliases.

Traditional syntax (Python 3.12 and earlier):

python
T = TypeVar("T", default=int)   This means that if no type is specified T = int

dataclass
class Box(Generic[T]):
 value: T | None = None

reveal_type(Box())                       type is Box[int]
reveal_type(Box(value="Hello World!"))   type is Box[str]


New syntax (Python 3.13+):

python
class Box[T = int]:
 def __init__(self, value: T) -> None:
     self.value = value

reveal_type(Box())                       type is Box[int]
reveal_type(Box(value="Hello World!"))   type is Box[str]


Type variable defaults work with all forms of generics, including classes, functions, and type aliases.
This release completes the implementation by fixing various edge cases involving recursive defaults,
dependencies between type variables, and interactions with variadic generics.

Contributed by Ivan Levkivskyi (PRs [21491](https://github.com/python/mypy/pull/21491),
[21526](https://github.com/python/mypy/pull/21526), [21544](https://github.com/python/mypy/pull/21544)).

Respect Explicit Return Type of `__new__()`

Mypy now respects explicitly annotated return types in `__new__()` methods. Previously, mypy would
always assume that `__new__()` returns an instance of the current class, ignoring explicit annotations.

With this change, if you explicitly annotate a return type that differs from the implicit type, mypy
will use the explicit annotation:

python
class Factory:
 def __new__(cls) -> Product:
     return Product()

reveal_type(Factory())   type is Product, not Factory


Note that mypy still gives an error at the definition site if the explicit annotation is not a
subtype of the current class, since this is technically not type-safe.

For backwards compatibility, there are two exceptions:
- If the return type is `Any`, mypy will still use the current class as the return type.
- If the explicit return type comes from a superclass and is a supertype of the implicit return type,
mypy will use the implicit (more specific) type:

python
class A:
 def __new__(cls) -> A: ...

reveal_type(A())   type is A

class B:
 def __new__(cls) -> B:
     return cls()

class C(B): ...
reveal_type(C())   type is C


This fixes several long-standing issues where explicit `__new__()` return types were ignored.

Contributed by Ivan Levkivskyi (PR [21441](https://github.com/python/mypy/pull/21441)).

TypeForm Support No Longer Experimental

Support for `TypeForm` is no longer experimental. `TypeForm` (introduced in Python 3.14) allows you
to annotate parameters that accept type expressions, providing better type checking for functions
that work with types as values.

python
from typing import TypeForm

def make_list(tp: TypeForm[T]) -> list[T]:
 ...

Correctly typed as list[int]
int_list = make_list(int)


`TypeForm` support was previously reverted from mypy 2.1 due to a performance regression, but this
has now been mitigated.

Contributed by Ivan Levkivskyi and Jelle Zijlstra (PRs [21262](https://github.com/python/mypy/pull/21262), [21591](https://github.com/python/mypy/pull/21591),
[21459](https://github.com/python/mypy/pull/21459)).

Experimental WASM Wheel for Python 3.14

Mypy now ships an experimental WebAssembly (WASM) wheel for Python 3.14. This allows mypy to run
in WASM environments such as Pyodide and browser-based Python implementations.

The WASM wheel is considered experimental and may have limitations compared to native builds. Please
report any issues you encounter when using mypy in WASM environments.

Contributed by Ivan Levkivskyi (PR [21671](https://github.com/python/mypy/pull/21671)).

Mypyc Free-threading Improvements

- Make function wrappers thread-safe on free-threaded builds (Jukka Lehtosalo, PR [21620](https://github.com/python/mypy/pull/21620))
- Make list remove and index thread-safe on free-threaded builds (Jukka Lehtosalo, PR [21614](https://github.com/python/mypy/pull/21614))
- Fix dict iteration memory safety on free-threaded builds (Jukka Lehtosalo, PR [21617](https://github.com/python/mypy/pull/21617))
- Make some dict primitives thread-safe on free-threading builds (Jukka Lehtosalo, PR [21616](https://github.com/python/mypy/pull/21616))
- Fix free-threading race condition in argument parsing (Jukka Lehtosalo, PR [21613](https://github.com/python/mypy/pull/21613))
- Document free threading and other doc updates (Jukka Lehtosalo, PR [21494](https://github.com/python/mypy/pull/21494))

`librt.strings` Updates

- Add `librt.strings.toupper` and `librt.strings.tolower` codepoint primitives (Vaggelis Danias, PR [21553](https://github.com/python/mypy/pull/21553))
- Add `librt.strings.isidentifier` codepoint primitive (Vaggelis Danias, PR [21522](https://github.com/python/mypy/pull/21522))
- Add `librt.strings.isalpha` codepoint primitive (Vaggelis Danias, PR [21521](https://github.com/python/mypy/pull/21521))
- Add `librt.strings.isalnum` codepoint primitive (Vaggelis Danias, PR [21509](https://github.com/python/mypy/pull/21509))
- Add `librt.strings.isdigit` codepoint primitive (Vaggelis Danias, PR [21504](https://github.com/python/mypy/pull/21504))
- Add `librt.strings.isspace` char primitive (Vaggelis Danias, PR [21462](https://github.com/python/mypy/pull/21462))

Mypyc Improvements

- Fix name lookup when class var and module var have the same name (Jukka Lehtosalo, PR [21594](https://github.com/python/mypy/pull/21594))
- Report file and line number on uncaught exceptions (Jukka Lehtosalo, PR [21584](https://github.com/python/mypy/pull/21584))
- Use `other` arg instead of `self` for RHS type (Ryan Heard, PR [21569](https://github.com/python/mypy/pull/21569))
- Use `method_sig` to get the method signature (Ryan Heard, PR [21567](https://github.com/python/mypy/pull/21567))
- Preserve inherited attribute defaults under `separate=True` (Jo, PR [21547](https://github.com/python/mypy/pull/21547))
- Fix missing cross-group header deps in incremental builds (Jo, PR [21490](https://github.com/python/mypy/pull/21490))
- Fix cross-group call to inherited `__mypyc_defaults_setup` (Jo, PR [21481](https://github.com/python/mypy/pull/21481))
- Fix non-deterministic class struct layout under `separate=True` (Vaggelis Danias, PR [21530](https://github.com/python/mypy/pull/21530))
- Specialize `s[i] == 'x'` to a codepoint int compare (Vaggelis Danias, PR [21579](https://github.com/python/mypy/pull/21579))
- Fix reference leak in mypyc bytes concatenation (Colinxu2020, PR [21469](https://github.com/python/mypy/pull/21469))

Fixes to Crashes

- Fix crash on invalid recursive variadic alias (Ivan Levkivskyi, PR [21572](https://github.com/python/mypy/pull/21572))
- Fix crashes on variadic unpacking in synthetic types (Ivan Levkivskyi, PR [21555](https://github.com/python/mypy/pull/21555))
- Fix crash on unhandled meet variadic tuple vs instance (Ivan Levkivskyi, PR [21558](https://github.com/python/mypy/pull/21558))
- Fix crash on deferred generic class nested in function (Ivan Levkivskyi, PR [21557](https://github.com/python/mypy/pull/21557))
- Fix crash in new-style type alias with variadic unpack (Ivan Levkivskyi, PR [21551](https://github.com/python/mypy/pull/21551))
- Fix various crashes on recursive type variable defaults (Ivan Levkivskyi, PR [21491](https://github.com/python/mypy/pull/21491))
- Fix crash for empty `Annotated` type application (Rayan Salhab, PR [21503](https://github.com/python/mypy/pull/21503))
- Fix crash on `Unpack` used without arguments in class bases (Sai Asish Y, PR [21470](https://github.com/python/mypy/pull/21470))

Performance Improvements

- Memoize the options snapshot (Kevin Kannammalil, PR [21354](https://github.com/python/mypy/pull/21354))
- Don't include `not_ready_deps` tracking as relating to mypy internals (Kevin Kannammalil, PR [21389](https://github.com/python/mypy/pull/21389))
- Speed up transitive dependency hash for singleton SCCs (Kevin Kannammalil, PR [21390](https://github.com/python/mypy/pull/21390))
- Optimize typeform checks (Jelle Zijlstra, PR [21459](https://github.com/python/mypy/pull/21459))

Improvements to the Native Parser

- Support `--shadow-file` with `--native-parser` (Jukka Lehtosalo, PR [21623](https://github.com/python/mypy/pull/21623))
- Add Python version checks to native parser (Kevin Kannammalil, PR [21539](https://github.com/python/mypy/pull/21539))
- Allow nativeparse to parse source code directly (bzoracler, PR [21260](https://github.com/python/mypy/pull/21260))

Other Notable Fixes and Improvements

- Add function definition notes for `too many positional arguments` errors (Kevin Kannammalil, PR [21410](https://github.com/python/mypy/pull/21410))
- Fix the exportjson tool (.ff cache to .json conversion) (Jukka Lehtosalo, PR [21628](https://github.com/python/mypy/pull/21628))
- Support floats in JSON in fixed-format cache (Ivan Levkivskyi, PR [21603](https://github.com/python/mypy/pull/21603))
- Update `TypedDictType.__init__` signature to preserve backward compat (Jukka Lehtosalo, PR [21590](https://github.com/python/mypy/pull/21590))
- Fix constructor calls for union-bounded `TypeVar`s (Jingchen Ye, PR [21571](https://github.com/python/mypy/pull/21571))
- Fix `TypedDict` indexing with literal keys in comprehensions (Jingchen Ye, PR [21556](https://github.com/python/mypy/pull/21556))
- Correctly handle empty tuple index when unpacked (Ivan Levkivskyi, PR [21545](https://github.com/python/mypy/pull/21545))
- Support protocol checks for self-types in tuple types (Ivan Levkivskyi, PR [21535](https://github.com/python/mypy/pull/21535))
- Fix edge cases in variadic tuple subclasses (Ivan Levkivskyi, PR [21518](https://github.com/python/mypy/pull/21518))
- Special-case constructor for tuple types (Ivan Levkivskyi, PR [21502](https://github.com/python/mypy/pull/21502))
- Fix false positive "Expected TypedDict key to be string literal" for `Union[TypedDict, dict[K, V]]` (Zakir Jiwani, PR [21511](https://github.com/python/mypy/pull/21511))
- Use explicit `Never` for type inference (Ivan Levkivskyi, PR [21497](https://github.com/python/mypy/pull/21497))
- Narrow membership in statically known containers (Shantanu, PR [21461](https://github.com/python/mypy/pull/21461))
- Improve negative narrowing for membership checks on tuples (Shantanu, PR [21456](https://github.com/python/mypy/pull/21456))
- Analyze `TypedDict` decorators (Pranav Manglik, PR [21267](https://github.com/python/mypy/pull/21267))
- Start testing Python 3.15 (Marc Mueller, PR [21439](https://github.com/python/mypy/pull/21439))
- Improved handling of `NamedTuple`, `TypedDict`, `Enum`, and regular classes nested in functions (Ivan Levkivskyi, PR [21478](https://github.com/python/mypy/pull/21478))

Typeshed Updates

Please see [git log](https://github.com/python/typeshed/commits/main?after=616424285beccaa76f90e87e1e922b1dc68710ca+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.

Acknowledgements

Thanks to all mypy contributors who contributed to this release:

- Adam Turner
- alicederyn
- bzoracler
- Colinxu2020
- georgesittas
- Ivan Levkivskyi
- Jelle Zijlstra
- Jingchen Ye
- Jukka Lehtosalo
- Kevin Kannammalil
- lphuc2250gma
- Marc Mueller
- Pranav Manglik
- Rayan Salhab
- Ryan Heard
- Sai Asish Y
- Shantanu
- sobolevn
- Vaggelis Danias
- Victor Letichevsky
- Zakir Jiwani

I'd also like to thank my employer, Dropbox, for supporting mypy development.

2.1

We’ve just uploaded mypy 2.1.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
Mypy is a static type checker for Python. This release includes new features, performance
improvements and bug fixes. You can install it as follows:

 python3 -m pip install -U mypy

You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).

librt.vecs: Fast Growable Array Type for Mypyc

The new `librt.vecs` module provides an efficient growable array type `vec` that is
optimized for mypyc use. It provides fast, packed arrays with integer and floating point
value types, which can be **several times faster** than `list`, and tens of times faster
than `array.array` in code compiled using mypyc. It also supports nested `vec` objects and
non-value-type items, such as ``vec[vec[str]]``.

Refer to the [documentation](https://mypyc.readthedocs.io/en/latest/librt_vecs.html) for
the details.

Contributed by Jukka Lehtosalo.

librt.random: Fast Pseudo-Random Number Generation

The new `librt.random` module provides fast pseudo-random number generation that is
optimized for code compiled using mypyc. It can be 3x to 10x faster than the stdlib
`random` module in compiled code.

Refer to the [documentation](https://mypyc.readthedocs.io/en/latest/librt_random.html) for
the details.

Contributed by Jukka Lehtosalo (PR [21433](https://github.com/python/mypy/pull/21433)).

Mypyc Improvements

- Enable incremental self-compilation (Vaggelis Danias, PR [21369](https://github.com/python/mypy/pull/21369))
- Make compilation order with multiple files consistent (Piotr Sawicki, PR [21419](https://github.com/python/mypy/pull/21419))
- Fix crash on accessing `StopAsyncIteration` (Piotr Sawicki, PR [21406](https://github.com/python/mypy/pull/21406))
- Fix incremental compilation with `separate` flag (Vaggelis Danias, PR [21299](https://github.com/python/mypy/pull/21299))

Fixes to Crashes

- Fix crash on partial type with `--allow-redefinition` and `global` declaration (Jukka Lehtosalo, PR [21428](https://github.com/python/mypy/pull/21428))
- Fix broken awaitable generator patching (Ivan Levkivskyi, PR [21435](https://github.com/python/mypy/pull/21435))

Changes to Messages

- Fix function call error message for small number of arguments (sobolevn, PR [21432](https://github.com/python/mypy/pull/21432))

Other Notable Fixes and Improvements

- Rely on typeshed stubs for `slice` typing (Ivan Levkivskyi, PR [21401](https://github.com/python/mypy/pull/21401))
- Narrow match captures based on previous cases (Shantanu, PR [21405](https://github.com/python/mypy/pull/21405))
- Fix nondeterminism in overload resolution (Shantanu, PR [21455](https://github.com/python/mypy/pull/21455))
- Respect file config comments for stale modules (Adam Turner, PR [21444](https://github.com/python/mypy/pull/21444))
- Fix JSON output mode for syntax errors in parallel mode (Adam Turner, PR [21434](https://github.com/python/mypy/pull/21434))
- Fix type variable with values as a supertype (Ivan Levkivskyi, PR [21431](https://github.com/python/mypy/pull/21431))
- Add support for configuring `--num-workers` with an environment variable (Kevin Kannammalil, PR [21407](https://github.com/python/mypy/pull/21407))
- Respect JSON output mode for syntax errors (Adam Turner, PR [21386](https://github.com/python/mypy/pull/21386))

Typeshed Updates

Please see [git log](https://github.com/python/typeshed/commits/main?after=e4d32e01bee44241a5e7c33298c261175b9f1bdb+0&branch=main&path=stdlib) for full list of standard library typeshed stub changes.

Acknowledgements

Thanks to all mypy contributors who contributed to this release:

- Adam Turner
- Ivan Levkivskyi
- Jukka Lehtosalo
- Kevin Kannammalil
- Piotr Sawicki
- Shantanu
- sobolevn
- Vaggelis Danias

I’d also like to thank my employer, Dropbox, for supporting mypy development.

2.0

We’ve just uploaded mypy 2.0.0 to the Python Package Index ([PyPI](https://pypi.org/project/mypy/)).
Mypy is a static type checker for Python. This release includes new features, performance
improvements and bug fixes. There are also changes to options and defaults.
You can install it as follows:

 python3 -m pip install -U mypy

You can read the full documentation for this release on [Read the Docs](http://mypy.readthedocs.io).

Enable `--local-partial-types` by Default

This flag affects the inference of types based on assignments in other scopes.
For now, explicitly disabling this continues to be supported, but this support will be removed
in the future as the legacy behaviour is hard to support with other current and future features
in mypy, like the daemon or the new implementation of flexible redefinitions.

Contributed by Ivan Levkivskyi, Jukka Lehtosalo, Shantanu in [PR 21163](https://github.com/python/mypy/pull/21163).

Enable `--strict-bytes` by Default

Per [PEP 688](https://peps.python.org/pep-0688), mypy no longer treats `bytearray` and `memoryview`
values as assignable to the `bytes` type.

Contributed by Shantanu in [PR 18371](https://github.com/python/mypy/pull/18371).

New Behavior for `--allow-redefinition`

The `--allow-redefinition` flag now behaves like `--allow-redefinition-new` in mypy 1.20
and earlier. The new behavior is generally more flexible. For example, you can have different
types for a variable in different blocks:

python
mypy: allow-redefinition

def foo(cond: bool) -> None:
 if cond:
     for x in ["a", "b"]:
          Type of "x" is "str" here
         ...
 else:
     for x in [1, 2]:
          Type of "x" is "int" here
         ...


The new behavior requires `--local-partial-types`, which is now enabled by default.

However, `--allow-redefinition` doesn't allow giving two type annotations for the same
variable. The old behavior (sometimes) allows this. Code like this now generates an error
when using `--allow-redefinition`:

python
def foo() -> None:
 x: list[int] = []
 ...
 x: list[str] = []   Error: "x" redefined
 ...


You can still use `--allow-redefinition-old` to fall back to the old behavior. We have no
plans to remove the legacy behavior, but the old functionality is maintained on a best effort
basis.

Contributed by Jukka Lehtosalo in [PR 21276](https://github.com/python/mypy/pull/21276).

Parallel Type Checking

Mypy now supports experimental parallel and incremental type checking. Use `--num-workers N`
or `-nN` to use `N` worker processes to type check in parallel. The speedup depends on the
import structure of your codebase and your environment, but for large projects we've seen
performance gains of **up to 5x** when using 8 worker processes.

Parallel type checking implicitly enables the new native parser. There are still some
minor semantic differences between parallel and non-parallel modes, which we will be fixing
in future mypy releases.

Contributed by Ivan Levkivskyi, with additional contributions from Emma Smith and Jukka
Lehtosalo.

Recent related changes since the last release:

- Freeze garbage collection in parallel workers for 4-5% speedup (Ivan Levkivskyi, PR [21302](https://github.com/python/mypy/pull/21302))
- Expose `--num-workers` and `--native-parser` (Ivan Levkivskyi, PR [21387](https://github.com/python/mypy/pull/21387))
- Split type checking into interface and implementation in parallel workers (Ivan Levkivskyi, PR [21119](https://github.com/python/mypy/pull/21119))
- Batch module groups for parallel processing (Ivan Levkivskyi, PR [21287](https://github.com/python/mypy/pull/21287))
- Optimize parallel worker startup (Ivan Levkivskyi, PR [21203](https://github.com/python/mypy/pull/21203))
- Parse files in parallel when possible (Ivan Levkivskyi, PR [21175](https://github.com/python/mypy/pull/21175))
- Use parallel parsing at all stages (Ivan Levkivskyi, PR [21266](https://github.com/python/mypy/pull/21266))
- Fix sequential bottleneck in parallel parsing (Jukka Lehtosalo, PR [21291](https://github.com/python/mypy/pull/21291))
- Fail fast when a user tries to generate reports with parallel workers (Ivan Levkivskyi, PR [21341](https://github.com/python/mypy/pull/21341))
- Partially support old NumPy plugin in parallel type checking (Ivan Levkivskyi, PR [21324](https://github.com/python/mypy/pull/21324))
- Handle reachability consistently in parallel type checking (Ivan Levkivskyi, PR [21322](https://github.com/python/mypy/pull/21322))
- Always respect `no_type_check` in parallel type checking (Ivan Levkivskyi, PR [21320](https://github.com/python/mypy/pull/21320))
- Minor fixes in parallel checking (Ivan Levkivskyi, PR [21319](https://github.com/python/mypy/pull/21319))
- Fix plugin logic in parallel type checking (Ivan Levkivskyi, PR [21252](https://github.com/python/mypy/pull/21252))
- Fix Windows IPC race condition when using parallel checking (Jukka Lehtosalo, PR [21228](https://github.com/python/mypy/pull/21228))
- Report parallel worker exit status on receive failure (Jukka Lehtosalo, PR [21224](https://github.com/python/mypy/pull/21224))

Drop Support for Targeting Python 3.9

Mypy no longer supports type checking code with `--python-version 3.9`.
Use `--python-version 3.10` or newer.

Contributed by Shantanu, Marc Mueller in [PR 21243](https://github.com/python/mypy/pull/21243).

Remove Special Casing of Legacy Bundled Stubs

Mypy used to bundle stubs for a few packages in versions 0.812 and earlier. To navigate the
transition, mypy used to report missing types for these packages even if `--ignore-missing-imports`
was set. Mypy now consistently respects `--ignore-missing-imports` for all packages.

Contributed by Shantanu in [PR 18372](https://github.com/python/mypy/pull/18372).

Prevent Assignment to None for Non-Optional Class Variables with Type Comments

Mypy used to allow assignment to None for class variables when using type comments. This was a
common idiom in Python 3.5 and earlier, prior to the introduction of variable annotations.
However, this was a soundness hole and has now been removed.

Contributed by Shantanu in [PR 20054](https://github.com/python/mypy/pull/20054).

librt.strings: String and Bytes Primitives for Mypyc

In mypy 1.20, we introduced [librt](https://pypi.org/project/librt/) as a standard library
for mypyc that fills in some gaps in the Python standard library and the C API.
This release adds the new module `librt.strings`, which contains utilities for building
string and bytes objects, and for accessing and generating binary data:

* `StringWriter` and `BytesWriter` classes allow quickly building `str` and `bytes` objects
from parts.
* `read_*` and `write_*` functions provide fast reading and writing of binary-encoded data.

Refer to the [documentation](https://mypyc.readthedocs.io/en/latest/librt_strings.html) for
the details.

Contributed by Jukka Lehtosalo.

Mypyc Improvements

- Document `librt.time` (Jukka Lehtosalo, PR [21372](https://github.com/python/mypy/pull/21372))
- Mark `librt.time.time()` non-experimental (Ivan Levkivskyi, PR [21310](https://github.com/python/mypy/pull/21310))
- Fix `librt.time` primitive now that it is no longer experimental (Ivan Levkivskyi, PR [21318](https://github.com/python/mypy/pull/21318))
- Fix `librt` API/ABI version checks (Jukka Lehtosalo, PR [21311](https://github.com/python/mypy/pull/21311))
- Generate more type methods for classes with attribute dictionaries (Piotr Sawicki, PR [21290](https://github.com/python/mypy/pull/21290))
- Fix reference counting for tuple items during deallocation (Shantanu, PR [21245](https://github.com/python/mypy/pull/21245))
- Release new instances when `__init__` raises (Shantanu, PR [21248](https://github.com/python/mypy/pull/21248))
- Fix `property` getter memory leak (Vaggelis Danias, PR [21230](https://github.com/python/mypy/pull/21230))
- Fix semantics for walrus expression in tuple (Shantanu, PR [21249](https://github.com/python/mypy/pull/21249))
- Fix crash on import errors during cleanup (Shantanu, PR [21247](https://github.com/python/mypy/pull/21247))
- Fix reference leak in str index (Shantanu, PR [21251](https://github.com/python/mypy/pull/21251))
- Fix memory leak in integer true division (Shantanu, PR [21246](https://github.com/python/mypy/pull/21246))
- Fix reference leaks in `list.clear()`/`dict.clear()` (Shantanu, PR [21244](https://github.com/python/mypy/pull/21244))
- Resolve type aliases in function specialization (esarp, PR [21233](https://github.com/python/mypy/pull/21233))
- Report an error if an acyclic class inherits from non-acyclic (Piotr Sawicki, PR [21227](https://github.com/python/mypy/pull/21227))
- Fix `b64decode` to match new CPython behavior (Piotr Sawicki, PR [21200](https://github.com/python/mypy/pull/21200))

Fixes to Crashes

- Fix crash when a file does not exist during semantic analysis (Ivan Levkivskyi, PR [21379](https://github.com/python/mypy/pull/21379))
- Fix parallel worker crash on syntax error (Ivan Levkivskyi, PR [21202](https://github.com/python/mypy/pull/21202))

Changes to Messages

- Improve error messages for unexpected keyword arguments in overloaded functions (Kevin Kannammalil, PR [20592](https://github.com/python/mypy/pull/20592))
- Don't suggest `Foo[...]` when `Foo(arg=...)` is used in annotation (Yosof Badr, PR [21238](https://github.com/python/mypy/pull/21238))
- Mention what codes are actually ignored in "not covered by type: ignore comment" note (wyattscarpenter, PR [19904](https://github.com/python/mypy/pull/19904))
- Improve error messages when positional argument is missing (Kevin Kannammalil, PR [20591](https://github.com/python/mypy/pull/20591))
- Improve "name is not defined" errors with fuzzy matching (Kevin Kannammalil, PR [20693](https://github.com/python/mypy/pull/20693))
- Add suggestions for misspelled module imports (Kevin Kannammalil, PR [20695](https://github.com/python/mypy/pull/20695))

Performance Improvements

- Replace `NamedTuple` with faster regular classes in hot paths (Shantanu, PR [21326](https://github.com/python/mypy/pull/21326))
- Avoid calling best-match suggestions unless the message is shown (Ivan Levkivskyi, PR [21307](https://github.com/python/mypy/pull/21307))
- Order cases in native parser based on AST node frequency (Jukka Lehtosalo, PR [21219](https://github.com/python/mypy/pull/21219))

Stubtest Improvements

- Basic support for unpack kwargs (Shantanu, PR [21024](https://github.com/python/mypy/pull/21024))
- Fix false positive for properties with a deleter (Pranav Manglik, PR [21259](https://github.com/python/mypy/pull/21259))

Documentation Updates

- Rename "value restriction" to "value-constrained type variable" (Leo Ji, PR [21112](https://github.com/python/mypy/pull/21112))
- Clarify that invariant-by-default applies to legacy `TypeVar` syntax (Leo Ji, PR [21108](https://github.com/python/mypy/pull/21108))

Improvements to the Native Parser

The new native parser is still experimental.

- Make new parser consistent with the old one (Ivan Levkivskyi, PR [21377](https://github.com/python/mypy/pull/21377))
- Support `--package-root` with the native parser (Ivan Levkivskyi, PR [21321](https://github.com/python/mypy/pull/21321))
- Improve call expressions in type annotations with the native parser (Jukka Lehtosalo, PR [21300](https://github.com/python/mypy/pull/21300))
- Depend on `ast-serialize` by default (Jukka Lehtosalo, PR [21297](https://github.com/python/mypy/pull/21297))

Other Notable Fixes and Improvements

- Fix narrowing for `AbstractSet` and `Mapping` (Shantanu, PR [21352](https://github.com/python/mypy/pull/21352))
- Preserve gradual guarantee when narrowing `Any` union via equality (Shantanu, PR [21368](https://github.com/python/mypy/pull/21368))
- Make type variable upper bound narrowing symmetric (Ivan Levkivskyi, PR [21350](https://github.com/python/mypy/pull/21350))
- Behave consistently when type-checking a stub package directly (Ivan Levkivskyi, PR [21330](https://github.com/python/mypy/pull/21330))
- Add sup

@pyup-bot

Copy link
Copy Markdown
Collaborator Author

Closing this in favor of #450

@pyup-bot pyup-bot closed this Jul 20, 2026
@madig
madig deleted the pyup-scheduled-update-2026-07-13 branch July 20, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant